package com.k12.common.listen;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.env.ConfigurableEnvironment;

@Slf4j
public class K12ApplicationListener implements ApplicationListener<ApplicationReadyEvent> {
    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        ConfigurableEnvironment environment = event.getApplicationContext().getEnvironment();
        String name = environment.getProperty("spring.application.name");
        String port = environment.getProperty("server.port");
        String env = environment.getProperty("spring.profiles.active");
        log.info("服务名称为:{} 的服务已启动成功 \n   启动的端口号为：{}  \n   所处环境为：{}", name, port, env);
    }
}
